package com.yjtc.cbg.commonutildemo.Util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Title: CommonUtilDemo
 * <p>
 * Description:
 * <p>
 * Author:baigege (baigegechen@gmail.com)
 * <p>
 * Date:2017-06-04
 */
public class SharePreferences {

    public boolean baocun(Context context, String numbuter, String password) {
        SharedPreferences sp = context.getSharedPreferences("date", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("username", numbuter);
        editor.putString("pwd", password);
        editor.commit();
        return true;
    }

    public String duqu(Context context, String numbuter) {
        SharedPreferences sp = context.getSharedPreferences("date", Context.MODE_PRIVATE);
        String password = sp.getString("pwd", "");
        if (password != null) {
            return password;
        } else {
            return null;
        }
    }

    public void baocuncheck(Context context, String number, boolean bool) {
        SharedPreferences sp = context.getSharedPreferences("date", Context.MODE_APPEND);
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean(number, bool);
        editor.commit();
    }

    public boolean duqucheck(Context context, String number) {
        SharedPreferences sp = context.getSharedPreferences("date", Context.MODE_APPEND);
        boolean b = sp.getBoolean(number, false);
        return b;
    }
}
